import request from '@/utils/request'

export function getDataCenters() {
  return request({
    url: '/datacenter/list',
    method: 'get'
  })
}

export function getInstances(dataCenter) {
  return request({
    url: '/datasource/instances',
    method: 'get',
    params: { dataCenter }
  })
}

export function getDatabases(dataCenter, instance) {
  return request({
    url: '/datasource/databases',
    method: 'get',
    params: { dataCenter, instance }
  })
}

export function getTables(dataCenter, instance, database) {
  return request({
    url: '/datasource/tables',
    method: 'get',
    params: { dataCenter, instance, database }
  })
}

// 获取表字段信息
export function getTableFields(dataCenter, instance, database, tableName) {
  return request({
    url: '/datasource/fields',
    method: 'get',
    params: {
      dataCenter,
      instance,
      database,
      tableName
    }
  })
}

// 清空数据源缓存
export function cleanCache() {
  return request({
    url: '/datasource/cleanCache',
    method: 'get'
  })
} 